package com.dime.physical.controller;



import com.dime.physical.domain.InputResult;
import com.dime.physical.domain.dto.SearchPhysicalregister;
import com.dime.physical.service.IDimeInputService;
import com.dime.physical.service.IDimePhysicalconsionService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.security.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 结果录入Controller
 *
 */
@RestController
@RequestMapping("/input")
public class DimeInputController extends BaseController {

    @Autowired
    private IDimeInputService dimeInputService;
    @Autowired
    private IDimePhysicalconsionService dimePhysicalconsionService;

    @GetMapping(value = "/list")
    public AjaxResult getGroup(SearchPhysicalregister searchPhysicalregister) {

        return success(dimeInputService.selectInputMainByUserId(searchPhysicalregister,SecurityUtils.getUserId().toString()));
    }

    @GetMapping(value = "/search/{checkCode}")
    public AjaxResult getDetail(@PathVariable("checkCode") String checkCode){
        return success(dimeInputService.selectInputMainByCheckCode(checkCode,SecurityUtils.getUserId().toString()));
    }

    @GetMapping(value = "/{groupId}")
    public AjaxResult getRegisters(@PathVariable("groupId") String groupId) {
        return success(dimeInputService.selectInputMainByGroupId(groupId,SecurityUtils.getUserId().toString()));
    }

    @GetMapping(value = "/{groupId}/{physicalId}")
    public AjaxResult getInputResult(@PathVariable("groupId") String groupId,
                              @PathVariable("physicalId") String physicalId) {

        return success(dimeInputService.selectInputResultByphysicalIdAndgroupId(groupId,physicalId));
    }

    @PostMapping
    public AjaxResult confirm(@RequestBody InputResult inputResult)
    {
        return toAjax(dimeInputService.updateInputResult(inputResult));
    }

    @DeleteMapping(value = "/{groupId}/{physicalId}")
    public AjaxResult cancel(@PathVariable("groupId") String groupId,@PathVariable("physicalId") String physicalId)
    {
        return toAjax(dimeInputService.deleteInputResult(groupId,physicalId));
    }

}
